<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\Major */

$this->title = '审核 ';
?>
<div class="major-create">	
	 <div class="panel">
        <div class="panel-body form-row">
            <div>
            <?= $this->render('view', [
		        'model' => $model,
                'ztDisplayName'=>$ztDisplayName,//状态显示(0 待审核 -1 驳回  1 审核通过)
		    ]) ?>
		    </div>
		   <div>
		       <?php $form = ActiveForm::begin(); ?>
               <?= $form->field($model, 'BHYY')->textInput(); ?>
               <div style='display:none'><?= $form->field($model, 'ZT')->dropDownList(['0'=>'待审核','-1'=>'驳回','1'=>"同意"] , ['prompt'=>'请选择']); ?></div>
               <div class="form-group">
               <?= Html::submitButton('驳回申请', ['class' => 'btn btn-danger act_reject']) ?>
               <?= Html::submitButton('审核通过', ['class' => 'btn btn-success act_agree']) ?>
               </div>
               <?php ActiveForm::end(); ?>     
    
		   </div>
		</div>
    </div>
    
</div>
<script>
<?php $this->beginBlock('majorAuditJS'); ?>
var majorAudit = {
	isInit:false,	
	init:function(){
		if(this.isInit == true){return;}
		
		$(".act_reject").on("click" , function(e){		
			$("#major-zt").val(-1)			
		})
		
		$(".act_agree").on("click" , function(){
			$("#major-zt").val(1)
		})
		
		$("#w1").on("submit" , function(){
			var bhyy = $("#major-bhyy").val().trim()
			var zt = parseInt($("#major-zt").val())
			if(bhyy == "" && zt == -1){
				majorAudit.alert("请填写驳回原因")
				return false
			}
		})
		
		this.isInit = true
	},

	//alert
	alert:function($content){
		if(window.parent.layer){
			window.parent.layer.alert($content)
		}else{
			alert($content)
		}
	}
}
majorAudit.init();

<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['majorAuditJS']); ?>
</script>